﻿@model Entidades.Sistema.Base.Empleado

<script type="text/javascript">
    //<![CDATA[
    var idEmpleado = null;
    function OnListBoxIndexChanged(s, e) {
        idEmpleado = lblEmpleado.GetValue();
        if (!cbpProducto.InCallback())
            cbpProducto.PerformCallback();
    }
    function OnBeginCallback(s, e) {
        e.customArgs["IdEmpleado"] = idEmpleado;
        idEmpleado = null;
    }
    function OnEndCallback(s, e) {
        if (idEmpleado != null)
            cbpProducto.PerformCallback();
    }
    // ]]>
</script>
@using (Html.BeginForm("PostAsignacionDeProductos", "EmpleadoProducto", FormMethod.Post, new { @class = "edit_form" }))
{
    
    @Html.Hidden("IdEmpleado")
   
        <div style="float: left">
        <label for="SelectionMode">Selecciona Empleado:</label>
            @Html.DevExpress().ListBox(
                settings => {
                    settings.Name = "lblEmpleado";
                    settings.Width = 150;
                    settings.Height = 350;
                    settings.Properties.EnableClientSideAPI = true;

                    settings.Properties.TextField = "NombreApellido";
                    settings.Properties.ValueField = "IdEmpleado";
                    settings.Properties.ValueType = typeof(Int32);
                    settings.SelectedIndex = 0;

                    settings.Properties.ClientSideEvents.ValueChanged = "OnListBoxIndexChanged";
                }).BindList(ViewData["Empleado"]).GetHtml()
        </div>
        <div style="float: left; padding-left: 2%">
            <div class="BottomPadding">Productos Asignados:</div>
            @Html.Partial("ListBoxProductos", Model)
        </div>
         <div class="line" >
             <div style="float: left">
            @Html.DevExpress().Label(
                settings => {
                    settings.ControlStyle.CssClass = "label";
                }
            ).GetHtml()
            @Html.DevExpress().Button(
                settings => {
                    settings.Name = "btnUpdate1";
                    settings.ControlStyle.CssClass = "button";
                    settings.Text = "Actualizar";
                    settings.UseSubmitBehavior = true;
                }
            ).GetHtml()
            @Html.DevExpress().Button(
                settings => {
                    settings.Name = "btnCancel1";
                    settings.ControlStyle.CssClass = "button";
                    settings.Text = "Cancelar";
                    settings.ClientSideEvents.Click = "function(s, e){ document.location='" + DevExpressHelper.GetUrl(new { Controller = "EmpleadoProducto", Action = "AsignacionDeProductos" }) + "'; }";
                }
            ).GetHtml() 

             </div>
        </div>
    
    if (ViewData["EditResult"] != null)
    {
        Html.ViewContext.Writer.Write(ViewData["EditResult"]);
    }
}